//
//  NetRequest.m
//  项目三
//
//  Created by rimi1 on 2016/11/25.
//  Copyright © 2016年 Wangxingqian. All rights reserved.
//

#import "NetRequest.h"
#import "UIResponder+CircleAnimation.h"

@implementation NetRequest

+ (void)getRequestWithUrl:(NSString *)url parameter:(NSDictionary *)parameter succeed:(Succeed)succeed failure:(Failure)failure {
    
    if ([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable) {
        [[RequestError sharedError] showErrorWithTitle:@"您的网络不给力啊，请检查网络"];
    }
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    [manager.requestSerializer setValue:@"cced1f98e1041697c7f57170834bffc9" forHTTPHeaderField:@"apikey"];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", @"text/html", nil];
    [manager GET:url parameters:parameter progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        succeed(responseObject);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(error);
    }];
}


@end













